home *** CD-ROM | disk | FTP | other *** search
/ Aminet 51 / Aminet 51 (2002)(GTI - Schatztruhe)[!][Oct 2002].iso / Aminet / util / arc / xadmasterdev.lha / xad / Sources / clients / SuperDuper3.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-08-20  |  3.5 KB  |  136 lines

  1. #ifndef XADMASTER_SUPERDUPER3_C
  2. #define XADMASTER_SUPERDUPER3_C
  3.  
  4. /* Programmheader
  5.  
  6.     Name:        SuperDuper3.c
  7.     Main:        xadmaster
  8.     Versionstring:    $VER: SuperDuper3.c 1.3 (29.08.1999)
  9.     Author:        SDI
  10.     Distribution:    Freeware
  11.     Description:    SuperDuper3 disk image client
  12.  
  13.  1.0   07.09.98 : first version
  14.  1.1   20.06.99 : removed exec.library calls
  15.  1.2   29.06.99 : now uses master free stuff
  16.  1.3   29.08.99 : now uses xdi_DataPos
  17. */
  18.  
  19. #include <proto/xadmaster.h>
  20. #include "SDI_compiler.h"
  21. #include "xadXPK.c"
  22.  
  23. #ifndef XADMASTERFILE
  24. #define SuperDuper3_Client    FirstClient
  25. #define NEXTCLIENT        0
  26. #define XADMASTERVERSION    8
  27. UBYTE version[] = "$VER: SuperDuper3 1.3 (29.08.1999)";
  28. #endif
  29. #define SUPERDUPER3_VERSION    1
  30. #define SUPERDUPER3_REVISION    3
  31.  
  32. ASM(BOOL) SuperDuper3_RecogData(REG(d0, ULONG size), REG(a0, STRPTR data),
  33. REG(a6, struct xadMasterBase *xadMasterBase))
  34. {
  35.   if(((ULONG *) data)[0] == 0x464F524D &&
  36.   (((ULONG *) data)[2] == 0x53444444 ||
  37.   ((ULONG *) data)[2] == 0x53444844))
  38.     return 1;
  39.   else
  40.     return 0;
  41. }
  42.  
  43. ASM(LONG) SuperDuper3_GetInfo(REG(a0, struct xadArchiveInfo *ai),
  44. REG(a6, struct xadMasterBase *xadMasterBase))
  45. {
  46.   LONG err;
  47.   ULONG dat[9], num = 0;
  48.   struct xadDiskInfo *xdi;
  49.  
  50.   if(!(xdi = (struct xadDiskInfo *) xadAllocObjectA(XADOBJ_DISKINFO, 0)))
  51.     return XADERR_NOMEMORY;
  52.   ai->xai_DiskInfo = xdi;
  53.  
  54.   if((err = xadHookAccess(XADAC_READ, 12, dat, ai)))
  55.     return err;
  56.  
  57.   xdi->xdi_EntryNumber = 1;
  58.   xdi->xdi_SectorSize = 512;
  59.   xdi->xdi_Cylinders = 80;
  60.   xdi->xdi_Heads = 2;
  61.   xdi->xdi_Flags = XADDIF_GUESSLOWCYL|XADDIF_GUESSHIGHCYL|XADDIF_SEEKDATAPOS;
  62. /*xdi->xdi_LowCyl = 0; */
  63.   xdi->xdi_DataPos = 12;
  64.   xdi->xdi_TrackSectors = dat[2] == 0x53444844 ? 22 : 11;
  65.   xdi->xdi_CylSectors = 2 * xdi->xdi_TrackSectors;
  66.   xdi->xdi_TotalSectors = 80 * xdi->xdi_CylSectors;
  67.  
  68.   while(ai->xai_InPos < ai->xai_InSize)
  69.   {
  70.     if((err = xadHookAccess(XADAC_READ, 36, dat, ai)))
  71.       return err;
  72.     if((err = xadHookAccess(XADAC_INPUTSEEK, dat[1]-28, 0, ai)))
  73.       return err;
  74.     ++num;
  75.     if(dat[0] == 0x58504B46 && (dat[8] & (1<<25)))
  76.     { /* check for password flag in every entry */
  77.       ai->xai_Flags |= XADAIF_CRYPTED;
  78.       xdi->xdi_Flags |= XADDIF_CRYPTED;
  79.     }
  80.   }
  81.  
  82.   if(num > 80)
  83.     return XADERR_ILLEGALDATA;
  84.  
  85.   xdi->xdi_HighCyl = num-1;
  86.  
  87.   return 0;
  88. }
  89.  
  90. ASM(LONG) SuperDuper3_UnArchive(REG(a0, struct xadArchiveInfo *ai),
  91. REG(a6, struct xadMasterBase *xadMasterBase))
  92. {
  93.   LONG i, err = 0;
  94.   struct {
  95.     STRPTR a;
  96.     ULONG  s;
  97.   } dat;
  98.  
  99.   /* skip entries */
  100.   for(i = ai->xai_CurDisk->xdi_LowCyl; !err && i < ai->xai_LowCyl; ++i)
  101.   {
  102.     if(!(err = xadHookAccess(XADAC_READ, 8, &dat, ai)))
  103.       err = xadHookAccess(XADAC_INPUTSEEK, dat.s, 0, ai);
  104.   }
  105.  
  106.   for(; !err && i <= ai->xai_HighCyl; ++i)
  107.   {
  108.     if(!(err = xadHookAccess(XADAC_READ, 8, &dat, ai)))
  109.     {
  110.       if(dat.a == (STRPTR) 0x58504B46)
  111.       {
  112.         if(!(err = xadHookAccess(XADAC_INPUTSEEK, -8, 0, ai)))
  113.         {
  114.           if(!(err = xpkDecrunch(&dat.a, &dat.s, ai, xadMasterBase)))
  115.           {
  116.             err = xadHookAccess(XADAC_WRITE, dat.s, dat.a, ai);
  117.             xadFreeObjectA(dat.a, 0);
  118.           }
  119.         }
  120.       }
  121.       else /* normal BODY chunk */
  122.         err = xadHookAccess(XADAC_COPY, dat.s, 0, ai);
  123.     }
  124.   }
  125.  
  126.   return err;
  127. }
  128.  
  129. const struct xadClient SuperDuper3_Client = {
  130. NEXTCLIENT, XADCLIENT_VERSION, XADMASTERVERSION, SUPERDUPER3_VERSION, SUPERDUPER3_REVISION,
  131. 12, XADCF_DISKARCHIVER|XADCF_FREEDISKINFO, XADCID_SUPERDUPER3, "SuperDuper3",
  132. (BOOL (*)()) SuperDuper3_RecogData, (LONG (*)()) SuperDuper3_GetInfo,
  133. (LONG (*)()) SuperDuper3_UnArchive, 0};
  134.  
  135. #endif /* XADMASTER_SUPERDUPER3_C */
  136.